<?php
//PHP计算当前日期几天或后几天日期的函数
function subDate($day, $date = "", $timestampFlag = true, $format = "Y-m-d H:i:s") {
    if (empty($date)) {
        $now = time();
    } else {
       // 注释: 不是时间截格式，是YYYY-mm-dd HH:ii:ss格式，将它们转换成时间戳格式
if (!is_numeric($date)) {
    $datetime_array = explode(" ", $date);
    $date_array = explode("-", $datetime_array[0]);
    $time_array = explode(":", $datetime_array[1]);
    $now = mktime($time_array[0], $time_array[1], $time_array[2], $date_array[1], $date_array[2], $date_array[0]);
} else {
    $now = $date;
}
}
    $m = $day * 24 * 60 * 60;
    $diff = $now + $m;
    if ($timestampFlag) {
        return $diff;
    } else {
        if (empty($format)) $format = "Y-m-d H:i:s";
        $oldday = date($format, $diff);
        return $oldday;
    }
}